package com.zhuo.mp.plugins;


import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.plugin.*;
import org.springframework.context.annotation.Bean;

import java.util.Properties;

@Intercepts({@Signature(
        type= Executor.class, //拦截的类型（Executor执行器）
        method = "update", //拦截执行器中的update方法
        args = {MappedStatement.class,Object.class})})
public class MyInterceptor implements Interceptor {//实现拦截器接口，实现下面三个方法
    @Override
    public Object intercept(Invocation invocation) throws Throwable {
        //拦截方法，具体业务逻辑编写的位置
        return invocation.proceed();
    }
    @Override public Object plugin(Object target) {
        //创建target对象的代理对象,目的是将当前拦截器加入到该对象中
        return Plugin.wrap(target, this);
    }
    @Override
    public void setProperties(Properties properties) {
        //属性设置
    }
}
